home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Graphics Samples / One Rectangle ƒ / one rectangle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-15  |  3.7 KB  |  117 lines  |  [TEXT/KAHL]

  1. /*
  2.     one rectangle.c
  3.     
  4.     This file contains the calls that an application needs to make for the "graphics shell" to work correctly.
  5.     This "one rectangle" will draw 1 black rectangle ( {0, 0, ff(100), ff(100)} ) in the upper left corner of the window.
  6.     
  7.     NOTES:
  8.     • This file requires the new "GX"-ified interface files and libraries. With the interface files, all types and function
  9.     names are proceeded by a "gx" for types or "GX" for function names.
  10.     
  11.     • This file requires the following files to run correctly:
  12.         "graphics shell .c", "ColorLibrary.c", "GraphicsDebugLibrary.c", "TransformLibrary.c".
  13.         
  14.     • This file prints the "best" in landscape mode.
  15.  
  16.     Change History:
  17.  
  18.        4/96    bob        Updated #includes to support changed GX Library names.
  19.                     Updated the note regarding the files needed to run.
  20.                     Updated the copyright date.
  21.     
  22.     ©1992 - 1996  Apple Computer, Inc.  All rights reserved.
  23. */
  24.  
  25. #include <events.h>
  26. #include <windows.h>
  27.  
  28. #include "GraphicsLibraries.h"
  29. #include <GXEnvironment.h>
  30. #include "graphics shell.h"
  31.  
  32. //
  33. //  Set up the title and size of the window 
  34. //
  35. Str255         gWindowTitle = "\p one rectangle ";
  36. Rect             gWindowQDRect  = {50, 50, 275, 275};
  37.  
  38. //     
  39. //    gGraphicsHeapSize sets the size of the graphics heap created by calling the NewGraphicsClient routine
  40. //    in main () within graphics shell.c.  You can determine the amount of graphics heap required by using GraphicsBug.
  41. //    With  gGraphicsHeapSize set to 25k, I had 2 free blocks left in the graphics heap. Sounds good to me.
  42. //
  43. long            gGraphicsHeapSize = 25;
  44.  
  45. gxShape         gShape;
  46.  
  47.  
  48. /*------ DoInitialization ---------------------------------------------------------------------------------*/
  49. //
  50. //    This function is creates the shape we want to draw on DoDraw
  51. //
  52.  
  53. void DoInitialization(gWindow)
  54. WindowPtr gWindow;
  55. {
  56.     gxRectangle         rectData = {0, 0, ff(100), ff(100)};    
  57.  
  58.     gShape = GXNewRectangle(&rectData); 
  59. }
  60.  
  61.  
  62. /*------ DoDraw ---------------------------------------------------------------------------------------*/
  63. //
  64. //    This function performs all of the drawing by calling GXDrawShape on our global shape - gShape.
  65. //
  66. void DoDraw( gWindow )
  67. WindowPtr gWindow;
  68. {
  69.     GXDrawShape ( gShape );
  70. }
  71.  
  72.  
  73. /*------ DoDispose -------------------------------------------------------------------------------------*/
  74. //
  75. //    This function tosses all of the shapes and the window we have created.
  76. //
  77. void DoDispose( gWindow )
  78. WindowPtr gWindow;
  79. {
  80.     //  
  81.     //    You should always dispose of your QuickDraw GX objects before tossing your window. Why? It's generally good 
  82.     //    form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
  83.     //    call to DisposeWindow should dispose of the objects. If you are running the debugging version of the 
  84.     //    "GXGraphics(debug)" extension with notices enabled, you will receive a notice that you had not disposed of
  85.     //    everything when you app quits. 
  86.     //
  87.     //    Notices are enabled within the "grahics shell.c" automatically, if you have installed the debug
  88.     //    extension. We determine if the debug init is installed by making the appropriate Gestalt call while the
  89.     //    graphics shell is starting up; see the "graphics shell.c" file for details.
  90.     //
  91.     GXDisposeShape( gShape );  
  92.      GXDisposeShape( gWindowBoundsShape );  
  93.         DisposeWindow( gWindow );
  94. }
  95.     
  96.  
  97.  
  98. /*------ DoClick ---------------------------------------------------------------------------------------*/
  99. //
  100. //    This function handles click by the user...
  101. //
  102. void DoClick( orgMouseLoc, theWindow )
  103. gxPoint        orgMouseLoc;
  104. WindowPtr     theWindow;
  105. {
  106. }
  107.  
  108.  
  109. /*------ DoIdle ----------------------------------------------------------------------------------------*/
  110. //
  111. //    This function is called within the event loop when the "graphics shell" receives a null event...
  112. //
  113. void DoIdle(gWindow)
  114. WindowPtr gWindow;
  115. {
  116. }
  117.